package com.multi.web.controller.common;

import com.multi.common.core.domain.AjaxResult;
import com.multi.common.utils.SecurityUtils;
import com.multi.publicly.domain.WxUserInfo;
import com.multi.publicly.service.PublicService;
import com.multi.publicly.vo.LoginFormVo;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;


/**
 * @Description 公共接口控制器
 * @ClassName PublicController
 * @Author pzj
 * @Data 2024/12/2 10:41
 */
@RestController
@RequestMapping("/public")
public class PublicController {

    @Autowired
    private PublicService publicService;

    /**
     * 获取用户电话信息
     * @return
     */
    @GetMapping("getPhone")
    public AjaxResult getPhone(String code,Long tenantId){
        String phone= publicService.getPhone(code,tenantId);
        return AjaxResult.success("success",phone);
    }

    /**
     * 微信用户登录操作，返回token信息
     * @param loginFormVo
     * @return
     */
    @PostMapping("login")
    public AjaxResult login(@Validated @RequestBody LoginFormVo loginFormVo){
        HashMap<String,Object> hashMap = publicService.login(loginFormVo);
        return AjaxResult.success(hashMap);
    }

    /**
     * 获取微信用户信息
     * @return
     */
    @GetMapping("getInfo")
    public AjaxResult getInfo(){
        WxUserInfo wxUserInfo= publicService.getInfo();
        return AjaxResult.success(wxUserInfo);
    }





}


